# 进行十折交叉

from sklearn.model_selection import KFold
import scipy.io as scio
import numpy as np

# 读取mat文件
def readMat(matPath):
    return scio.loadmat(matPath)

# 加载数据集
matPath = '../dataSet20180402.mat'
dataSet = readMat(matPath)
print('数据集读取完成')

# 读取数据集
test = np.array(dataSet['test'])
testX = np.array(dataSet['testX'])
testY = np.array(dataSet['testY'])
train = np.array(dataSet['train'])
trainX = np.array(dataSet['trainX'])
trainY = np.array(dataSet['trainY'])
print('数据集读取完成')

kf=KFold(n_splits=10)
trainXData=[]
trainYData=[]
validateXData=[]
validateYData=[]
for trainIndex, validateIndex in kf.split(trainX):
    txdTemp=trainX[trainIndex]
    tydTemp=trainY[trainIndex]
    trainXData.append(txdTemp)
    trainYData.append(tydTemp)

    vxdTemp=trainX[validateIndex]
    vydTemp=trainY[validateIndex]
    validateXData.append(vxdTemp)
    validateYData.append(vydTemp)


